package 结构化小测;

import java.util.Arrays;
import java.util.Scanner;

public class one {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int w = scanner.nextInt();
        int n = scanner.nextInt();
        int a[] = new int[n];
        int count = 0;
        for(int i=0;i<n ;i++) {
            a[i] = scanner.nextInt();
        }
        Arrays.sort(a);
        int c = 0;
        int j = 0;
        for(int i=n-1; i>=0; i--){
           if(i==j) {//两者价格相等
               c++;
               break;
           }
           if(a[i]+a[j]>w){//两者相加之和大于限定值w
               c++;
           }
           else if(a[i]+a[j]<=w&&(i-j==1)){//两者相加小于等于w且位置接近,c+1,结束
               c++;
               break;
           }
           else if(a[i]+a[j]>w&&(i-j==1)){//两者相加大于w且位置接近,c+2，结束
               c+=2;
               break;
           }
           else{//正常情况
                c++;
                j++;
           }
        }
            System.out.println(c);
        }

}
